package com.ruoyi.project.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouse.domain.WareWarehouseTotal;
import com.ruoyi.project.warehouse.service.IWareWarehouseTotalService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 总仓库Controller
 * 
 * @author 萧雪
 * @date 2022-09-03
 */
@RestController
@RequestMapping("/warehouse/WareWarehouseTotal")
public class WareWarehouseTotalController extends BaseController
{
    @Autowired
    private IWareWarehouseTotalService wareWarehouseTotalService;

    /**
     * 查询总仓库列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:list')")
    @GetMapping("/list")
    public TableDataInfo list(WareWarehouseTotal wareWarehouseTotal)
    {
        startPage();
        List<WareWarehouseTotal> list = wareWarehouseTotalService.selectWareWarehouseTotalList(wareWarehouseTotal);
        return getDataTable(list);
    }

    /**
     * 导出总仓库列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:export')")
    @Log(title = "总仓库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WareWarehouseTotal wareWarehouseTotal)
    {
        List<WareWarehouseTotal> list = wareWarehouseTotalService.selectWareWarehouseTotalList(wareWarehouseTotal);
        ExcelUtil<WareWarehouseTotal> util = new ExcelUtil<WareWarehouseTotal>(WareWarehouseTotal.class);
        util.exportExcel(response, list, "总仓库数据");
    }

    /**
     * 获取总仓库详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wareWarehouseTotalService.selectWareWarehouseTotalById(id));
    }

    /**
     * 新增总仓库
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:add')")
    @Log(title = "总仓库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WareWarehouseTotal wareWarehouseTotal)
    {
        return toAjax(wareWarehouseTotalService.insertWareWarehouseTotal(wareWarehouseTotal));
    }

    /**
     * 修改总仓库
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:edit')")
    @Log(title = "总仓库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WareWarehouseTotal wareWarehouseTotal)
    {
        return toAjax(wareWarehouseTotalService.updateWareWarehouseTotal(wareWarehouseTotal));
    }

    /**
     * 删除总仓库
     */
    @PreAuthorize("@ss.hasPermi('warehouse:WareWarehouseTotal:remove')")
    @Log(title = "总仓库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wareWarehouseTotalService.deleteWareWarehouseTotalByIds(ids));
    }
}
